package com.springboot.news.domain.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.springboot.news.anno.Status;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.groups.Default;
import java.time.LocalDateTime;

@Data
public class Article {
    private Integer id;
    @Pattern(regexp = "^\\S{1,10}$")
    private String title;
    @NotEmpty
    private String content;
    @NotEmpty
    @URL
    private String coverImg;
    @Status
    private String status;
    private Integer createUser;
    @NotNull
    private Integer categoryId;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
    public interface Add extends Default{};
    public interface Update extends Default{};

//    @Status是自定义注解校验
//    自定义注解分三步
//    1.在anno页面定义Status解方法。
//    2.在validation包下定义方法。
//    3.在需要用的地方添加注解
}
